package com.example.offer.no0009;

import java.util.Arrays;

import com.example.offer.no0009.impl.SolutionImpl;

/**
 * 解答测试-重建二叉树
 *
 * @author yumuhui
 */
public class SolutionTest {

    public static void main(String[] a1rgs) {

//        // 期望结果[null,null,3,-1]
//        String[] opArr = new String[]{"CQueue","appendTail","deleteHead","deleteHead"};
//        Integer[] numArr = new Integer[]{null, 3, null, null};

        // 期望结果[null,-1,null,null,5,2]
        String[] opArr = new String[]{"CQueue", "deleteHead", "appendTail", "appendTail", "deleteHead", "deleteHead"};
        Integer[] numArr = new Integer[]{null, null, 5, 2, null, null};


        System.out.println("入参: opArr: " + Arrays.toString(opArr));
        System.out.println("入参: numArr: " + Arrays.toString(numArr));

        Solution solution = new SolutionImpl();

        int size = opArr.length;

        Integer[] res = new Integer[size];

        for (int i = 0; i < size; i++) {
            String op = opArr[i];
            Integer num = numArr[i];
            switch (op) {
                case "CQueue":
                    solution.CQueue();
                    res[i] = null;
                    break;
                case "appendTail":
                    solution.appendTail(num);
                    res[i] = null;
                    break;
                case "deleteHead":
                    int head = solution.deleteHead();
                    res[i] = head;
                    break;
                default:
                    res[i] = null;
            }
        }

        System.out.println("结果: res: " + Arrays.toString(res));
    }
}
